﻿#ifndef JZWEB_PAGE_H_
#define JZWEB_PAGE_H_

#include <QObject>
#include "JZWebWidget.h"

//JZWebPage
class JZWebPage : public QObject
{
	Q_OBJECT

public:
	JZWebPage();
	virtual ~JZWebPage();

	virtual QString render() = 0;
	virtual QJsonObject onCommand(const QJsonObject& obj);

	JZWebContext *baseContext();
	
	JZWebContext *currentContext();
	void setCurrentContext(JZWebContext* ctx);

protected:
	JZWebContext* m_currentContext;
	JZWebContext m_context;
};

//JZWebWidgetPage
class JZWebWidgetPage : public JZWebPage
{
	Q_OBJECT

public:
	JZWebWidgetPage();
	virtual ~JZWebWidgetPage();

	virtual QString render();
	virtual QJsonObject onCommand(const QJsonObject& obj);
	JZWebWidgetRoot* root();

	int generateId();

protected:
	int m_widgetId;
	QString m_html;
	JZWebWidgetRoot *m_root;
};

//JZWebStaticPage
class JZWebStaticPage : public JZWebPage
{
	Q_OBJECT

public:
	JZWebStaticPage();
	virtual ~JZWebStaticPage();

	virtual QString render();

	void setFile(const QString& file);

signals:
	void sigCommand(const QJsonObject &obj);

protected:
	QString m_filePath;
	QString m_html;
};


#endif // !JZWEB_PAGE_H_
